package com.tianji.learning.service.impl;

import com.tianji.api.dto.user.UserDTO;
import com.tianji.common.utils.ObjectUtils;
import com.tianji.learning.domain.po.PointsBoard;
import com.tianji.learning.domain.query.PointsBoardQuery;
import com.tianji.learning.domain.vo.PointsBoardItemVO;
import com.tianji.learning.domain.vo.PointsBoardVO;
import com.tianji.learning.mapper.PointsBoardMapper;
import com.tianji.learning.service.IPointsBoardService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static com.tianji.common.utils.DateUtils.SIGN_DATE_SUFFIX_FORMATTER;
import static com.tianji.learning.constans.RedisConstants.POINTS_BOARDS_KEY_PREFIX;

/**
 * <p>
 * 学霸天梯榜 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-11-18
 */
@Service
public class PointsBoardServiceImpl extends ServiceImpl<PointsBoardMapper, PointsBoard> implements IPointsBoardService {

    @Override
    public PointsBoardVO queryPointsBoardBySeason(PointsBoardQuery query) {
        // 1、判断是否是查询当前赛季
        Long season = query.getSeason();
        boolean isCurrentSeanson = ObjectUtils.isEmpty(season) || season == 0;

        // 2、查询我的榜单信息
        String key = POINTS_BOARDS_KEY_PREFIX+ LocalDateTime.now().format(SIGN_DATE_SUFFIX_FORMATTER);
        PointsBoard myBoard =isCurrentSeanson? queryMyCurrentBoard(key) : queryMyHistoryBoard(season);
        // 3、查询排行榜信息
        List<PointsBoard> boards =  isCurrentSeanson ?
                queryCurrentBoardList(key,query.getPageNo(),query.getPageSize()) :
                queryHistoryBoardList(query);

        // 4、封装返回
        // 4.1、封装我的榜单信息


        // 4.2、封装排行榜信息


        // 4.2.1、查询用户信息


        // 4.2.2、循环组装volist

        return null;
    }

    private List<PointsBoard> queryHistoryBoardList(PointsBoardQuery query) {
        return null;
    }

    private List<PointsBoard> queryCurrentBoardList(String key, Integer pageNo, Integer pageSize) {
        return null;
    }

    private PointsBoard queryMyHistoryBoard(Long season) {
        return null;
    }

    private PointsBoard queryMyCurrentBoard(String key) {
        return null;
    }
}
